package com.heima.article.controller.v1;

import com.heima.article.service.IApArticleService;
import com.heima.model.article.dtos.ApArticleHomeDTO;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "APP 端文章访问 API")
@RestController
@RequestMapping("api/v1/article")
public class ApArticleController {

    @Autowired
    private IApArticleService apArticleService;

    @ApiOperation(value = "根据频道 id 查询文章列表", notes = "APP 端首页加载时渲染文章数据")
    @PostMapping("load")
    public ResponseResult findArticlesByLoad(@RequestBody ApArticleHomeDTO apArticleHomeDTO){
        return apArticleService.findArticlesByChannel(apArticleHomeDTO);
    }

    @ApiOperation(value = "根据频道 id 查询文章列表", notes = "APP 端首页上拉时渲染文章数据")
    @PostMapping("loadmore")
    public ResponseResult findArticlesByLoadMore(@RequestBody ApArticleHomeDTO apArticleHomeDTO){
        return apArticleService.findArticlesByChannel(apArticleHomeDTO);
    }

    @ApiOperation(value = "根据频道 id 查询文章列表", notes = "APP 端首页下拉时渲染文章数据")
    @PostMapping("loadnew")
    public ResponseResult findArticleByLoadNew(@RequestBody ApArticleHomeDTO apArticleHomeDTO){
        return apArticleService.findArticlesByChannel(apArticleHomeDTO);
    }

}
